﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;
using SES.CMS.AdminCP;

namespace SES.CMS.Module
{
    public partial class ucSearch_home : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["lang"].ToString() == "VN")
                {
                    Functions.ddlDatabinder(ddlProductType, cmsLoaiSanPhamDO.LOAISANPHAMID_FIELD, cmsLoaiSanPhamDO.TENLOAISANPHAM_FIELD, new cmsLoaiSanPhamBL().SelectAll(0));
                }
                else
                {
                    Functions.ddlDatabinder(ddlProductType, cmsLoaiSanPhamDO.LOAISANPHAMID_FIELD, cmsLoaiSanPhamDO.ETENSANPHAM_FIELD, new cmsLoaiSanPhamBL().SelectAll(0));
                }
            }

        }

        protected void ddlProductType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlProduct.Enabled = true;
            //if (!IsPostBack)
            //{
                if (Session["lang"].ToString() == "VN")
                {
                    Functions.ddlDatabinder(ddlProduct, cmsSanPhamDO.SANPHAMID_FIELD, cmsSanPhamDO.TENSANPHAM_FIELD, new cmsSanPhamBL().SelectSanPhamByLoaiSP(int.Parse(ddlProductType.SelectedValue)));
                }
                else
                {
                    Functions.ddlDatabinder(ddlProduct, cmsSanPhamDO.SANPHAMID_FIELD, cmsSanPhamDO.ETENSANPHAM_FIELD, new cmsSanPhamBL().SelectSanPhamByLoaiSP(int.Parse(ddlProductType.SelectedValue)));
                }
            //}
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtSearchbox.Text != "")
            {
                Response.Redirect("/Search.aspx?ID=" + txtSearchbox.Text);
            }
        }
    }
}